<template>
  <div v-if="browserRedirect">
    <div class="divTopSty">
      <div style="display: flex;justify-content: space-between;">
        <img v-if="!imageurl" style="width: 70px;height: 70px;position: relative;top: 15px;border-radius: 50px;" src="../../assets/touxa.jpg" alt="头像">
        <img v-else style="width: 70px;height: 70px;position: relative;top: 15px;border-radius: 50px;" :src="imageurl" alt="头像">
        <div style="color:#fff;">
          <div style="height:36px;">
            <span style="font-size: 14px;font-weight: bold;">账号：{{initData.userName}} </span>
          </div>
          <div style="height:36px;">
            <span style="font-size: 14px;font-weight: bold;">名称：{{factory_name}}</span>
          </div>
          <div style="height:36px;">
            <span style="font-weight: bold;">电话：{{initData.phone}}</span style="float: right;">
          </div>
        </div>
        <div style="padding: 6px 0;">
          <img v-if="approveStatus==1" style="margin-top: -3px;margin-left:5px;" src="../../assets/homepage-icon-identify.svg">
          <img v-if="approveStatus!=1" style="margin-top: -3px;margin-left:5px;" src="../../assets/homepage-icon-NOidentify.svg">
          <span v-if="approveStatus==1" style="font-size: 14px;font-weight: bold;color:#FFA518;">已认证</span>
          <span v-if="approveStatus!=1" style="font-size: 14px;font-weight: bold;color:#FF5252;">未认证</span>
        </div>
      </div>
      <div style='display: flex;justify-content: space-between;color:#fff;'>
        <div>
          <div style="text-align: center;font-size: 24px;">{{products_total}}</div>
          <div style="font-size: 12px;">共上传作品数</div>
        </div>
        <div>
          <div style="text-align: center;font-size: 24px;">{{shopkeeper_total}}</div>
          <div style="font-size: 12px;">店铺使用数</div>
        </div>
        <div>
          <div style="text-align: center;font-size: 24px;">{{yesterday_scan_total}}</div>
          <div style="font-size: 12px;">昨日玩家扫码验证人数</div>
        </div>
      </div>
    </div>
    <div style="background-color: #fff;border-radius: 6px;width:90%;padding:15px;display: flex;justify-content: space-between;height:50px;margin:0 auto;margin-top:-30px;">
      <div style="width:140px;">
        <img style="margin-top: -5px;" src="../../assets/homepage-icon-numShop.svg"/>
        <span style="color: #333;font-weight: bold;">门店申请</span>
        <img style="float: right;margin-top: 5px;margin-right: -5px;" @click="jumpApplyList" src="../../assets/home-icon-arrowRight.svg">
        <span style="float: right;margin-right: 5px;">6</span>
      </div>
      <div style="width:140px;margin-left:20px;">
        <img style="margin-top: -5px;" src="../../assets/home-icon-sort.svg"/>
        <span style="color: #333;font-weight: bold;">销量排行</span>
        <img style="float: right;margin-top: 5px;" src="../../assets/home-icon-arrowRight.svg">
      </div>
    </div>
    <div>
      <div class="extra-wrapper" slot="tabBarExtraContent" style="padding:0;margin-bottom: -20px;margin-top:5px">
        <a-select defaultValue="" @change="changeSpecification" style="width:90%;margin-left: 5%;">
          <a-select-option key="" value="">请选择</a-select-option> 
          <a-select-option v-for="(val,index) in colList" :key="val.itemPatch" :value="val.id">{{val.productName+"/批次-"+val.itemPatch}}</a-select-option>
        </a-select>
      </div>
      <a-tabs @change="callback" default-active-key="1" size="large" :tab-bar-style="{marginBottom: '24px', paddingLeft: '16px'}">
        <a-tab-pane loading="true" tab="在售剧本" key="1" style="min-height: 100vh;">
          <ul style="margin: 0;padding:0;list-style-type: none;">
            <li v-for="val in dataSource" class="liCommSty">
              <div style="display: flex;border-bottom: 1px solid #EBEBEB;padding-bottom: 20px;">
                <img v-if="val.personPoster.indexOf(',') == -1" :src="val.personPoster" style="width:90px;height:90px;" alt="产品海报图">
                <img v-if="val.personPoster.indexOf(',') != -1" :src="val.personPoster.split(',')[0]" style="width:90px;height:90px;" alt="产品海报图">
                <span v-if="!val.personPoster" style="width:90px;height:90px;text-align: center;line-height: 90px;">暂无图片</span>
                <div style="padding-left:15px;">
                  <div style="font-size: 14px;font-weight: bold;">
                    <span>{{val.productName}}</span>
                    <span style="position: absolute;right: 15px;" @click="detailsCli(val,2)">详情</span>
                  </div>
                  <div style="font-size: 14px;font-weight: bold;color:#888;max-height: 50px;overflow: hidden;text-overflow: ellipsis;">一句话简介：{{val.productInfo}}</div>
                  <div style="font-size: 14px;font-weight: bold;color:#666;">
                    <span>总量：{{val.total}}</span>
                    <span style="position: absolute;right: 15px;color:#FF5252;font-size: 16px;">¥{{val.wholesalePrice}}</span>
                  </div>
                </div>
              </div>
              <div style="margin-top: 20px;">
                <span>作者</span>
                <span style="float: right;">{{val.author}}</span>
              </div>
              <div style="margin-top: 10px;">
                <span>正式发售时间</span>
                <span style="float: right;">{{val.publicTime}}</span>
              </div>
              <div style="margin-top: 10px;">
                <span>批次</span>
                <span style="float: right;">{{val.itemPatch}}</span>
              </div>
            </li>
          </ul>
          <a-pagination showQuickJumper :defaultCurrent="ipagination.current" :total="ipagination.total" @change="onChange"/>
        </a-tab-pane>
      </a-tabs>
    </div>
    <BlockProductStandardsAll v-if="showAll" :listData="listData" @returnUp="returnUp"></BlockProductStandardsAll>
  </div>
  <div class="page-header-index-wide" v-else>
    <a-row :gutter="24">
      <a-col :sm="24" :md="12" :xl="6" :style="{ marginBottom: '24px' }">
        <div class="borderSty">
          <p>
            <img src="../../assets/homepage-icon-numShop.svg" style="position: relative;top: -2px;">
            <span style="font-size: 16px;font-weight: bold;color: rgba(0, 0, 0, 0.45);">共上传作品数</span>   
          </p>
          <p style="height:84px;padding-left:3px;color: #000;margin-top: 4px;margin-bottom: 0;font-size: 30px;line-height: 38px;">
            {{products_total}}
          </p>
        </div>
      </a-col>
      <a-col :sm="24" :md="12" :xl="6" :style="{ marginBottom: '24px' }">
        <div class="borderSty">
          <p>
            <img src="../../assets/homepage-icon-numUser.svg" style="position: relative;top: -2px;">
            <span style="font-size: 16px;font-weight: bold;color: rgba(0, 0, 0, 0.45);">店铺使用数</span>   
          </p>
          <p style="height:84px;padding-left:3px;color: #000;margin-top: 4px;margin-bottom: 0;font-size: 30px;line-height: 38px;border-bottom: 1px solid #e8e8e8;">
            {{shopkeeper_total}}
            <!-- <span style="position: relative;top: -4px;margin-left: 16px;font-size:16px;font-weight: bold;" :class="shopkeeper_total?'greenColor':'redColor'">
              <Icon type="arrow-up" ></Icon> 0.00%
            </span> -->
          </p>
          <p style="margin-top:6px;color: #1890FF;font-weight: 500;cursor: pointer;" @click="jump(3)">详情</p>
        </div>
      </a-col>
      <a-col :sm="24" :md="12" :xl="6" :style="{ marginBottom: '24px' }">
        <div class="borderSty">
          <p>
            <img src="../../assets/homepage-icon-numWork.svg" style="position: relative;top: -2px;">
            <!-- <span style="font-size: 16px;font-weight: bold;color: rgba(0, 0, 0, 0.45);">昨日玩家参加组局人数</span>    -->
            <span style="font-size: 16px;font-weight: bold;color: rgba(0, 0, 0, 0.45);">昨日玩家扫码验证人数</span>
          </p>
          <p style="height:84px;padding-left:3px;color: #000;margin-top: 4px;margin-bottom: 0;font-size: 30px;line-height: 38px;border-bottom: 1px solid #e8e8e8;">
            {{yesterday_scan_total}}
            <!-- <span style="position: relative;top: -4px;margin-left: 16px;font-size:16px;font-weight: bold;" :class="shopkeeper_total?'greenColor':'redColor'">
              <Icon type="arrow-up" ></Icon> 0.00%
            </span> -->
          </p>
          <p style="margin-top:6px;color: #1890FF;font-weight: 500;cursor: pointer;" @click="jump(4)">详情</p>
        </div>
      </a-col>
      <a-col :sm="24" :md="12" :xl="6" :style="{ marginBottom: '24px' }" v-if="userAuth2btn == 2 || userAuth2btn == 3 || userAuth2btn == 4">
        <div class="borderSty">
          <p>
            <img src="../../assets/homepage-icon-numWork.svg" style="position: relative;top: -2px;">
            <!-- <span style="font-size: 16px;font-weight: bold;color: rgba(0, 0, 0, 0.45);">昨日玩家参加组局人数</span>    -->
            <span style="font-size: 16px;font-weight: bold;color: rgba(0, 0, 0, 0.45);">店家总人数</span>
          </p>
          <p style="height:84px;padding-left:3px;color: #000;margin-top: 4px;margin-bottom: 0;font-size: 30px;line-height: 38px;border-bottom: 1px solid #e8e8e8;">
            {{userTotal}}
            <!-- <span style="position: relative;top: -4px;margin-left: 16px;font-size:16px;font-weight: bold;" :class="shopkeeper_total?'greenColor':'redColor'">
              <Icon type="arrow-up" ></Icon> 0.00%
            </span> -->
          </p>
          <p style="margin-top:6px;color: #1890FF;font-weight: 500;cursor: pointer;" @click="jump(6)">详情</p>
        </div>
      </a-col>
      <a-col :sm="24" :md="12" :xl="6" :style="{ marginBottom: '24px' }"  v-if="userAuth2btn == 1">
        <!-- <chart-card :loading="loading" title="  " total="" style="padding-top:20px"> -->
        <div class="borderSty">
          <div style="display: flex;height: 123px;border-bottom: 1px solid #e8e8e8;">
            <div style="width:30%;">
              <img v-if="!imageurl" style="width: 70px;height: 70px;position: relative;top: 15px;border-radius: 50px;" src="../../assets/touxa.jpg" alt="头像">
              <img v-else style="width: 70px;height: 70px;position: relative;top: 15px;border-radius: 50px;" :src="imageurl" alt="头像">
            </div>
            <div style="width:80%;">
              <div style="height:36px;">
                <span style="font-size: 14px;font-weight: bold;">账号：{{initData.userName}} </span>
              </div>
              <div style="height:36px;">
                <span style="font-size: 14px;font-weight: bold;">名称：{{factory_name}}</span>
              </div>
              <div style="height:36px;">
                <a-icon type="phone" :style="{ fontSize: '16px' }"/>
                <span style="font-weight: bold;margin-left:10px;">{{initData.phone}}</span style="float: right;">
              </div>
            </div>
          </div>
          <div style="display: flex;justify-content: space-between;">
            <span style="margin-top:6px;color: #1890FF;font-weight: 500;cursor: pointer;" @click="jump(2)">编辑</span>
            <div style="padding: 6px 0;">
              <img v-if="approveStatus==1" style="margin-top: -3px;margin-left:5px;" src="../../assets/homepage-icon-identify.svg">
              <img v-if="approveStatus!=1" style="margin-top: -3px;margin-left:5px;" src="../../assets/homepage-icon-NOidentify.svg">
              <span v-if="approveStatus==1" style="font-size: 14px;font-weight: bold;color:#FFA518;">已认证</span>
              <span v-if="approveStatus!=1" style="font-size: 14px;font-weight: bold;color:#FF5252;">未认证</span>
            </div>
          </div>
        </div>
        <!-- </chart-card> -->
      </a-col>
    </a-row>    
    <div style="background-color: #fff;margin-top:-10px;border-radius: 10px;margin-bottom: -25px;">
      <div style="padding:16px;font-size: 18px;font-weight: bold;">流程引导</div>
      <div style="margin:-15px 0 40px 0;display: flex;width: 560px;padding-left: 50%;margin-left: -300px;padding-bottom: 40px;">
        <span style="display: inline-block;position: relative;min-width: 85px;cursor: pointer;height: 83px;" @click="jumpStep(1)">
          <img style="width: 50px;margin-left: 25%;margin-bottom: 50px;" src="../../assets/icon-step1.svg" alt="完善信息">
          <span style="position: absolute;left: 17px;top: 58px;font-weight: bold;">完善信息</span>
          <img style="width: 20px;position: relative;left: 108px;top: -80px;" src="../../assets/icon-stepArrow.svg" alt="完善信息">
        </span>
        <span style="display: inline-block;margin-left:70px;position: relative;cursor: pointer;min-width: 85px;height: 83px;" @click="jumpStep(2)">
          <img style="width: 50px;margin-left: 25%;margin-bottom: 50px;" src="../../assets/icon-step2.svg" alt="添加剧本">
          <span style="position: absolute;left: 17px;top: 58px;font-weight: bold;">添加在售剧本</span>
          <img style="width: 20px;position: relative;left: 108px;top: -80px;" src="../../assets/icon-stepArrow.svg" alt="添加剧本">
        </span>
        <span style="display: inline-block;margin-left:70px;position: relative;cursor: pointer;min-width: 85px;height: 83px;">
          <img style="width: 50px;margin-left: 25%;margin-bottom: 50px;" src="../../assets/icon-step3.svg" alt="申请二维码">
          <span style="position: absolute;left: 12px;top: 58px;width: 100%;font-weight: bold;">申请二维码</span>
          <img style="width: 20px;position: relative;left: 108px;top: -80px;" src="../../assets/icon-stepArrow.svg" alt="申请二维码">
        </span>
        <span style="display: inline-block;margin-left:70px;position: relative;cursor: pointer;min-width: 85px;height: 83px;" @click="jumpStep(3)">
          <img style="width: 50px;margin-left: 25%;margin-bottom: 50px;" src="../../assets/icon-step4.svg" alt="剧本绑定">
          <span style="position: absolute;left: 17px;top: 58px;font-weight: bold;width:100%;">剧本绑定</span>
        </span>
      </div>
    </div>
    <a-card :loading="loading" :bordered="false" :body-style="{padding: '0'}">
      <div class="salesCard">
        <a-tabs @change="callback" class="tabsSty" default-active-key="1" size="large" :tab-bar-style="{marginBottom: '24px', paddingLeft: '16px'}">
            <div class="extra-wrapper" slot="tabBarExtraContent">
              <a-select defaultValue="" @change="changeSpecification1" class="selSty" style="left:480px;">
                <a-select-option key="" value="">请选择</a-select-option> 
                <a-select-option v-for="(val,index) in dataSource1List" :key="val.itemPatch" :value="val.productName">{{val.productName+"/批次-"+val.itemPatch}}</a-select-option>
              </a-select>
              <a-select defaultValue="" @change="changeSpecification" class="selSty">
                <a-select-option key="" value="">请选择</a-select-option> 
                <a-select-option v-for="(val,index) in colList" :key="val.itemPatch" :value="val.id">{{val.productName+"/批次-"+val.itemPatch}}</a-select-option>
              </a-select>
              <Button type="primary" style='margin-right:30px;' @click="jump(5)">添加在售剧本</Button>
            </div>
          <a-tab-pane loading="true" tab="在售剧本" key="1">
            <a-row style="padding:0 15px 28px 15px;" class="rowTab">
                  <a-table
                :columns="columns"
                :dataSource="dataSource"
                :pagination="ipagination"
                :loading="loading"
                @change="handleTableChange">
                <template slot="htmlSlot" slot-scope="text, record">
                  <div style="height:90px;display: flex;">
                    <div style="display: inline-block;">
                      <img v-if="record.personPoster && record.personPoster.indexOf(',') == -1" :src="record.personPoster" style="width:90px;height:90px;" alt="产品海报图">
                      <img v-if="record.personPoster && record.personPoster.indexOf(',') != -1" :src="record.personPoster.split(',')[0]" style="width:90px;height:90px;" alt="产品海报图">
                      <span v-if="!record.personPoster" style="width:90px;height:90px;text-align: center;line-height: 90px;">暂无图片</span>
                    </div>
                    <div style="display: inline-block;line-height: 26px;margin-left:10px;">
                      <div style="font-size: 14px;font-weight: bold;">{{record.productName}}</div>
                      <div style="font-size: 14px;font-weight: bold;color:#888;max-height: 50px;overflow: hidden;text-overflow: ellipsis;">一句话简介：{{record.productInfo}}</div>
                      <div style="font-size: 14px;font-weight: bold;color:#666;">批次：{{record.itemPatch}}</div>
                    </div>
                  </div>
                </template>
                <template slot="total" slot-scope="text, record">
                  <div style="font-size: 14px;font-weight: bold;">{{record.total+"/"+(record.total-record.bindNumber)}}</div>
                </template>
                <template slot="imgSlot" slot-scope="text">
                  <span v-if="!text" style="font-size: 12px;font-style: italic;">无此图片</span>
                  <img v-else :src="getImgView(text)" height="25px" alt="图片不存在" style="max-width:80px;font-size: 12px;font-style: italic;"/>
                </template>
                <template slot="fileSlot" slot-scope="text">
                  <span v-if="!text" style="font-size: 12px;font-style: italic;">无此文件</span>
                  <a-button
                    v-else
                    :ghost="true"
                    type="primary"
                    icon="download"
                    size="small"
                    @click="uploadFile(text)">
                    下载
                  </a-button>
                </template>
    
                <span slot="action" slot-scope="text, record">
                  <!-- <a v-if="!record.total" @click="handleEdit(record)">编辑</a>
                  <a v-if="!record.total"-divider type="vertical" /> -->
                  <a v-if="record.applyStatus == null" href="javascript:;" @click="codeCli(record)">申请正版码</a>
                  <a-divider v-if="record.applyStatus == null" type="vertical" />
                  <a v-if="record.applyStatus == null || record.applyStatus == 2" href="javascript:;" @click="detailsCli(record,1)">编辑</a>
                  <a-divider v-if="record.applyStatus == null || record.applyStatus == 2" type="vertical" />
                  <a v-if="record.applyStatus == 0 || record.applyStatus == 1 || record.applyStatus == 3" href="javascript:;" @click="addItemPath(record)">增加批次</a>
                  <a-divider v-if="record.applyStatus == 0 || record.applyStatus == 1 || record.applyStatus == 3" type="vertical" />
                  <a v-if="record.applyStatus == 0 || record.applyStatus == 1 || record.applyStatus == 3" href="javascript:;" @click="detailsCli(record,2)">详情</a>
                  <a-divider v-if="record.applyStatus == 0 || record.applyStatus == 1 || record.applyStatus == 3" type="vertical" />
                  <!-- <a href="javascript:;" @click="deleteCli(record)">删除</a> -->
                  <a-popconfirm title="确定删除吗?" @confirm="() => deleteCli(record)">
                    <a>删除</a>
                  </a-popconfirm>
                </span>
              </a-table>
            </a-row>
          </a-tab-pane>
          <a-tab-pane loading="true" tab="预售剧本" key="2">
            <a-row style="padding:0 15px 28px 15px;" class="rowTab">
                  <a-table
                :columns="columns"
                :dataSource="dataSource1"
                :pagination="ipagination1"
                :loading="loading"
                @change="handleTableChange1">
                <template slot="htmlSlot" slot-scope="text, record">
                  <div style="height:90px;display: flex;">
                    <div style="display: inline-block;" v-if="record.personPoster">
                      <img v-if="record.personPoster && record.personPoster.indexOf(',') == -1" :src="record.personPoster" style="width:90px;height:90px;" alt="产品海报图">
                      <img v-if="record.personPoster && record.personPoster.indexOf(',') != -1" :src="record.personPoster.split(',')[0]" style="width:90px;height:90px;" alt="产品海报图">
                      <!-- <img v-if="!val.personPoster" src="" alt="暂无图片"> -->
                      <span v-if="!record.personPoster" style="width:90px;height:90px;text-align: center;line-height: 90px;">暂无图片</span>
                    </div>
                    <div style="display: inline-block;line-height: 26px;margin-left:10px;">
                      <div style="font-size: 14px;font-weight: bold;">{{record.productName}}</div>
                      <div style="font-size: 14px;font-weight: bold;color:#888;max-height: 50px;overflow: hidden;text-overflow: ellipsis;">一句话简介：{{record.productInfo}}</div>
                      <div style="font-size: 14px;font-weight: bold;color:#666;">批次：{{record.itemPatch}}</div>
                    </div>
                  </div>
                </template>
                <template slot="imgSlot" slot-scope="text">
                  <span v-if="!text" style="font-size: 12px;font-style: italic;">无此图片</span>
                  <img v-else :src="getImgView(text)" height="25px" alt="图片不存在" style="max-width:80px;font-size: 12px;font-style: italic;"/>
                </template>
                <template slot="fileSlot" slot-scope="text">
                  <span v-if="!text" style="font-size: 12px;font-style: italic;">无此文件</span>
                  <a-button
                    v-else
                    :ghost="true"
                    type="primary"
                    icon="download"
                    size="small"
                    @click="uploadFile(text)">
                    下载
                  </a-button>
                </template>
    
                <span slot="action" slot-scope="text, record">
                  <a href="javascript:;" @click="detailsCli(record)">详情</a>
                  <a-divider type="vertical" />
                  <a href="javascript:;" @click="handleOkFuter(record.id)">预售转在售</a>
                </span>
              </a-table>
            </a-row>
          </a-tab-pane>
        </a-tabs>
      </div>
      <!-- <div class="salesCard">
        <a-tabs default-active-key="1" size="large" :tab-bar-style="{marginBottom: '24px', paddingLeft: '16px'}">
          <div class="extra-wrapper" slot="tabBarExtraContent">
            <a-select defaultValue="" @change="changeSpecification1" class="selSty">
              <a-select-option key="" value="">请选择</a-select-option> 
              <a-select-option v-for="(val,index) in dataSource1List" :key="val.itemPatch" :value="val.productName">{{val.productName+"/批次-"+val.itemPatch}}</a-select-option>
            </a-select>
          </div>          
        </a-tabs>
      </div> -->
      <a-modal title="转在售剧本" v-model="visible" @ok="handleOk" style="text-align: center;">
        <p>您确定要将该剧本转为在售剧本吗，此操作不可撤销，请谨慎操作！</p>
      </a-modal>
      <a-modal title="增加批次" :confirmLoading="showTrue" v-model="visibleAgean" @ok="handleAgainOk" style="text-align: center;">
        <div>
          <span>批次：</span>
          <a-input style="width:50%;" placeholder="请输入批次" v-model="itemPathVal"></a-input>
        </div>
        <div style="margin-top:20px;">
          <span>总量：</span>
          <a-input-number :min="1" :max="100" style="width:50%;" placeholder="请输入总量" v-model="totalVal"></a-input-number>
        </div>
      </a-modal>
      <BlockProductStandardsAll v-if="showAll" :listData="listData" @returnUp="returnUp"></BlockProductStandardsAll>
      <BlockProductApplyModal v-if="showCode" :listCodeData="listCodeData" @returnUp="returnUp"></BlockProductApplyModal>
      <blockProductStandards-modal ref="modalForm" @ok="modalFormOk"></blockProductStandards-modal>
    </a-card>
  </div>
</template>

<script>
  import { Button,Icon,Modal } from 'ant-design-vue';
  import { browserRedirect } from '@/utils/util'
  // import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import ChartCard from '@/components/ChartCard'
  import ACol from "ant-design-vue/es/grid/Col"
  import ATooltip from "ant-design-vue/es/tooltip/Tooltip"
  import MiniArea from '@/components/chart/MiniArea'
  import MiniBar from '@/components/chart/MiniBar'
  import MiniProgress from '@/components/chart/MiniProgress'
  import RankList from '@/components/chart/RankList'
  import Bar from '@/components/chart/Bar'
  import LineChartMultid from '@/components/chart/LineChartMultid'
  import HeadInfo from '@/components/tools/HeadInfo.vue'
  import { getAction,putAction,deleteAction,postAction } from '@/api/manage'
  import { axios } from '@/utils/request'
  import { mapActions, mapGetters,mapState } from 'vuex'
  import {initDictOptions, filterMultiDictText} from '@/components/dict/JDictSelectUtil'
  import BlockProductStandardsAll from '../block/modules/BlockProductStandardsAll'
  import BlockProductApplyModal from './BlockProductApplyModal.vue'
  import BlockProductStandardsModal from '../block/modules/BlockProductStandardsModal'

  import Trend from '@/components/Trend'
  import { getLoginfo,getHomeData } from '@/api/api'

  export default {
    name: "IndexChart",
    // mixins:[JeecgListMixin],
    components: {
      BlockProductStandardsModal,
      ATooltip,
      ACol,
      ChartCard,
      MiniArea,
      MiniBar,
      MiniProgress,
      RankList,
      Bar,
      Icon,
      Trend,
      LineChartMultid,
      HeadInfo,
      Button,
      Modal,
      BlockProductStandardsAll,
      BlockProductApplyModal
    },
    data() {
      return {
        userTotal:0,
        userAuth2btn:"",
        browserRedirect:false,
        approveStatus:"",
        showTrue:false,
        itemPatchList:"",
        visibleAgean:false,
        itemPathVal:"",
        totalVal:"",
        visible: false,
        imageurl:"",
        showAll:false,
        showCode:false,
        urlImg:"",
        listData:{},
        dataSource1:[],
        dataSource1List:[],
        ipagination1:{
          current: 1,
          pageSize: 10,
          showTotal: (total, range) => {
            return range[0] + "-" + range[1] + " 共" + total + "条"
          },
          showQuickJumper: true,
          total: 0
        },
        ipagination:{
          current: 1,
          pageSize: 10,
          showSizeChanger:false,
          showTotal: (total, range) => {
            return range[0] + "-" + range[1] + " 共" + total + "条"
          },
          showQuickJumper: true,
          total: 0
        },
        products_total:"0",
        shopkeeper_total:"0",
        yesterday_scan_total:"0",
        user_avatar:"",
        factory_name:"",
        loading: true,
        center: null,
        dataSource:[],
        loginfo:{},
        colList:[],
        listCodeData:{},
        initData:{
          createBy: "",
          createTime: "",
          flag: "",
          id: "",
          loginTime: "",
          manufacturerId: "",
          phone: "",
          updateBy: "",
          updateTime: "",
          userName: ""
        },
        issuerId:"",
        futerId:"",
        // url: {
        //   list: "/block/blockProductStandards/list"
        // },
        columns: [
          // {
          //   title: '#',
          //   dataIndex: '',
          //   key:'rowIndex',
          //   width:60,
          //   align:"center",
          //   customRender:function (t,r,index) {
          //     return parseInt(index)+1;
          //   }
          // },
          {
            title:'剧本名称',
            align:"left",
            width:"25%",
            dataIndex: 'productName',
            scopedSlots: { customRender: 'htmlSlot' }
          },
          {
            title:'作者',
            align:"center",
            dataIndex: 'author'
          },
          {
            title:'总量/剩余',
            align:"center",
            dataIndex: 'total',
            scopedSlots: { customRender: 'total' }
          },
          {
            title:'零售价格',
            align:"center",
            dataIndex: 'wholesalePrice'
          },
          {
            title:'标签',
            align:"center",
            dataIndex: 'labelTags'
          },
          {
            title:'正式发行时间',
            align:"center",
            dataIndex: 'publicTime'
          },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            scopedSlots: { customRender: 'action' }
          }
        ],
      }
    },
    mounted() {
      this.browserRedirect = browserRedirect();
      // this.urlImg = window._CONFIG['imgDomainURL']+'/';
      this.urlImg ="";
      this.initLogInfo();
      this.indataList();
      this.listInfo();
      this.futerList();
      getAction("/block/blockManufacturerInfo/userAuth2btn")
        .then(res => {
          if (res.success) {
            this.userAuth2btn = res.result.status;
            if(res.result.status == 3){
              this.issuerId = "";
              this.listInfoSingUp();
              return
            }
            let list={
              column: "createTime",
              order: "desc",
              field: "id,,factoryName,companyProfile,createTime,type,name,status,address,phone,imageurl,action",
              pageNo: 1,
              pageSize: 5
            };
            getAction("/block/blockManufacturerInfo/list",list).then((res)=>{
              if (res.success) {
                this.issuerId = res.result.records[0].id;
                this.listInfoSingUp();
              } else {
                this.$message.warning(res.message)
              }
            })
          } else {
            this.$message.warning(res.message)
          }
        })
    },
    methods: {
      jumpApplyList(){
        this.$router.push('/block/BlockProductShopApplyList')
      },
      onChange(pageNumber) {
        this.ipagination.current = pageNumber;
        this.indataList();
      },
      addItemPath(record){
        this.itemPatchList = record;
        this.itemPathVal="";
        this.totalVal="";
        this.visibleAgean=true;
      },
      handleAgainOk(){
        if(!this.itemPathVal){
          this.$message.warning("请输入批次！");
          return
        }
        if(!this.totalVal){
          this.$message.warning("请输入总量！");
          return
        }
        this.itemPatchList.applyStatus=0;
        this.itemPatchList.id="";
        this.itemPatchList.itemPatch = this.itemPathVal;
        this.itemPatchList.total = this.totalVal;
        this.showTrue=true;
        postAction("/block/blockProductStandards/add",this.itemPatchList).then((res) => {
          this.showTrue=false;
          if(res.success){
            this.visibleAgean=false;
            this.indataList();
            this.$message.success(res.message);
          }else{
            this.$message.warning(res.message);
          }
        })
      },
      handleOk(e){
        this.visible = false;
        putAction("/exhibition/exhibition_product_standards_new/preSaleToSale",{id:this.futerId}).then((res) => {
          if(res.success){
            this.$message.success(res.message);
          }else{
            this.$message.warning(res.message);
          }
        })
      },
      handleOkFuter(id){
        this.futerId = id;
        this.visible = true;
      },
      callback(key){
        if(key == 1){
          this.indataList();
        }
        if(key == 2){
          this.futerList();
        }
      },
      listInfoSingUp(){
        getAction("https://blockinsight.com.cn/scriptPlay/third/yesterdayBoostNum?issuerId="+this.issuerId).then((res) => {
          if (res.success) {
            this.yesterday_scan_total = res.data;
          }
          if(res.code===510){
            this.$message.warning(res.message)
          }
        })
      },
      listInfo(){
        var that = this;
        let list={
          column: "createTime",
          order: "desc",
          field: "id,,factoryName,companyProfile,createTime,type,name,status,address,phone,imageurl,action",
          pageNo: 1,
          pageSize: 5
        };
        getAction("/block/blockManufacturerInfo/list",list).then((res)=>{
          if (res.success) {
            this.userTotal = res.result.total;
            this.approveStatus = res.result.records[0].status;
            if(res.result.records[0].imageurl){
              that.imageurl = res.result.records[0].imageurl;
            }else{
              that.imageurl = "";
            }
            that.$forceUpdate();
          } else {
            that.$message.warning(res.message)
          }
        })        
      },
      jumpStep(num){
        if(num == 1){
          this.$router.push("/block/BlockManufacturerInfoMessageList")
        }
        if(num == 2){
          this.$router.push("/block/BlockProductInfoList")
        }
        if(num == 3){
          this.$router.push("/block/BlockProductBindInfoList")
        }
      },
      modalFormOk() {
        this.indataList();
      },
      deleteCli(record){
        var param={
            id:record.id
          };
        deleteAction("/block/blockProductStandards/delete",param).then((res) => {
            if (res.success) {
              this.$message.success(res.message);
              this.indataList();
            }
            if(res.code===510){
              this.$message.warning(res.message)
            }
          })
      },
      codeCli(record){
        postAction("/block/blockProductStandards/judgeDataIntergrity?id="+record.id,{'id':record.id}).then((res) => {
            if (!res.success) {
              this.$message.warning("剧本信息不完整,请先补充完整剧本信息！")
              this.detailsCli(record,1);
            }else{
              if(record.applyStatus == 2 || record.applyStatus == null){
                this.showCode = true;
                this.listCodeData = record;
              }else if(record.applyStatus == 0){
                this.$message.success("您的二维码正在等待审核，请耐心等待！")
              }else if(record.applyStatus == 1){
                this.$message.success("您的二维码审批已通过！")
              }else{
                this.$message.success("您的二维码正在审核中，请耐心等待！")
              }
            }
          })
      },
      futerList(){
        var param={
            order: "asc",
            field: "",
            pageNo: this.ipagination1.current,
            pageSize: 10
          };
        getAction("exhibition/exhibition_product_standards_new/getShowData").then((res) => {
            if (res.success) {
              this.ipagination1.total = res.result.total;
              this.dataSource1 = res.result;
              this.dataSource1List = res.result;
            }
            if(res.code===510){
              this.$message.warning(res.message)
            }
          })
      },
      changeSpecification1(value,option){
        if(value==""){
          this.futerList();
        }else{
          var params={
            productName: value,
            itemPatch:option.key,
            column:"createTime",
            order: "asc",
            field: "",
            pageNo: 1,
            pageSize: 10
          };
          getAction("exhibition/exhibition_product_standards_new/getShowData",params).then((res) => {
            if (res.success) {
              this.dataSource1 = res.result;
              this.ipagination1.total = res.result.total;
            }
            if(res.code===510){
              this.$message.warning(res.message)
            }
          })
        }
      },
      changeSpecification(value,option){
        if(value==""){
          this.indataList();
        }else{
          var params={
            productStandardsId: value,
            id:value,
            itemPatch:option.key,
            order: "asc",
            pageNo: this.ipagination.current,
            pageSize: 10
          };
          getAction("/block/blockProductStandards/listToHome",params).then((res) => {
            if (res.success) {
              this.dataSource = res.result.records;
              this.ipagination.total = res.result.total;
            }
            if(res.code===510){
              this.$message.warning(res.message)
            }
          })
        }
      },
      ...mapGetters(["nickname", "avatar","userInfo"]),
      getAvatar(){
        return window._CONFIG['imgDomainURL']+"/"+this.avatar()
      },
      handleTableChange(pagination, filters, sorter) {
        //TODO 筛选
        if (Object.keys(sorter).length > 0) {
          this.isorter.column = sorter.field;
          this.isorter.order = 'ascend' === sorter.order ? 'asc' : 'desc';
        }
        this.ipagination = pagination;
        this.indataList();
      },
      handleTableChange1(pagination, filters, sorter) {
        //TODO 筛选
        if (Object.keys(sorter).length > 0) {
          this.isorter.column = sorter.field;
          this.isorter.order = 'ascend' === sorter.order ? 'asc' : 'desc';
        }
        this.ipagination1 = pagination;
        this.futerList();
      },
      detailsCli(record,num){
        if(num == 1){
          this.$forceUpdate();
          // this.handleEdit(record);
          this.$refs.modalForm.edit(record);
          this.$refs.modalForm.title = "编辑";
          this.$refs.modalForm.disableSubmit = false;
        }else{
          this.showAll=true;
          this.listData = record;
        }
      },
      returnUp(data){
        this.showAll = data;
        this.showCode = data;
        this.indataList();
      },
      jump(num){
        if(num == 1){
          this.$router.push("/block/BlockCategoryList")
        }
        if(num == 2){
          this.$router.push("/block/BlockManufacturerInfoMessageList")
        }
        if(num == 3){
          this.$router.push("/block/BlockCustomerInfoList")
        }
        if(num == 4){
          this.$router.push("/block/BlockCustomerSearchList")
        }
        if(num == 5){
          this.$router.push("/block/BlockProductInfoList")
        }
        if(num == 6){
          this.$router.push("/block/BlockManufacturerInfoList")
        }
      },
      indataList(){
        var params={
          order: "asc",
          pageNo: this.ipagination.current,
          pageSize: 10
        };
        getAction("/block/blockProductStandards/listToHome",params).then((res) => {
          if (res.success) {
            this.dataSource = res.result.records;
            this.colList = res.result.records;
            this.ipagination.total = res.result.total;
          }
          if(res.code===510){
            this.$message.warning(res.message)
          }
          this.loading = false;
        })
      },
      initLogInfo () {
        getAction("/block/blockManufacturerInfo/getHomeData").then((res) => {
          if (res.success) {
            if(res.result.manufacturerUser){
              this.initData = res.result.manufacturerUser;
            }
            this.products_total = res.result.products_total.toString();
            this.shopkeeper_total = res.result.shopkeeper_total.toString();
            this.shopkeeper_total = res.result.shopkeeper_total.toString();
            this.user_avatar = res.result.user_avatar;
            this.factory_name = res.result.factory_name;
          }
          if(res.code===510){
            this.$message.warning(res.message)
          }
          this.loading = false;
        })
      },
    }
  }
</script>

<style lang="scss" scoped>
  .tabsSty /deep/ .ant-tabs-tab:last-child{
    margin-left: 219px;
  }
  .liCommSty{
    background-color: #fff;
    padding:15px;
    margin-bottom: 10px;
    border-radius: 6px;
  }
  .divTopSty{
    background-color: #404B70;
    height:225px;
    padding:20px 10px;
  }
  .selSty{
    width: 12%;
    position: absolute;
    left: 140px;
    top: 16px;
    z-index: 10;
  }
  .rowTab /deep/ .ant-table-fixed-header .ant-table-scroll .ant-table-header {
    overflow: scroll hidden !important;
  }
  .greenColor{
    color: #00c39b;
  }
  .redColor{
    color: #FF4767;
  }
  .borderSty{
    background: #fff;
    height:181px;
    border-radius: 4px;
    padding: 20px 24px 8px;
  }
  .circle-cust{
    position: relative;
    top: 28px;
    left: -100%;
  }
  .extra-wrapper {
    line-height: 55px;
    padding-right: 24px;

    .extra-item {
      display: inline-block;
      margin-right: 24px;

      a {
        margin-left: 24px;
      }
    }
  }

  /* 首页访问量统计 */
  .head-info {
    position: relative;
    text-align: left;
    padding: 0 32px 0 0;
    min-width: 125px;

    &.center {
      text-align: center;
      padding: 0 32px;
    }

    span {
      color: rgba(0, 0, 0, .45);
      display: inline-block;
      font-size: .95rem;
      line-height: 42px;
      margin-bottom: 4px;
    }
    p {
      line-height: 42px;
      margin: 0;
      a {
        font-weight: 600;
        font-size: 1rem;
      }
    }
  }
</style>